A double trim function. This function separates the input values in three categories defined by the 窶彡窶 and the 窶彭窶 parameters. Assuming that the 窶彡窶 parameter is below the 窶彭窶 parameter, the function behaves as follows:
If the input value is less than the 窶彡窶 parameter, the output value is equal to the 窶彙窶 parameter.
If the input value is between the 窶彡窶 and the 窶彭窶 parameters, the output value is calculated according to the following linear function:
Output = b + (Input - c)(a - b)/(d - c)
If the input value is greater than the 窶彭窶 parameter, the output value is equal to the 窶彗窶 parameter.
If the 窶彭窶 parameter is less than or equal to the 窶彡窶 parameter, the 窶彭窶 parameter is ignored, and the function behaves exactly like the Thresh1 function. In such cases you should simply use the Thresh1 function instead to avoid confusion.
Note that the 窶彗窶 parameter does not have to be greater than the 窶彙窶 parameter. To obtain useful results, however, the 窶彗窶 parameter should not be equal to the 窶彙窶 parameter. (If you let 窶彗窶 be equal to 窶彙窶, the output value will always be equal to this common value.)
In the special case when 窶彗窶 is equal to 窶彭窶, 窶彙窶 is equal to 窶彡窶, and 窶彡窶 is less than 窶彭窶, the Trim2 function takes the following simplified form:
Output = Max(Min(Input, a), b)
Hence, in this case input values less than 窶彙窶 are replaced by 窶彙窶, input values greater than 窶彗窶 are replaced by 窶彗窶, and all other input values are passed on unchanged.